-- [yue]: init.yue
local Path = Dora.Path -- 1
local Content = Dora.Content -- 1
local AudioBus = Dora.AudioBus -- 1
local Audio = Dora.Audio -- 1
local App = Dora.App -- 1
local setmetatable = _G.setmetatable -- 1
local Node = Dora.Node -- 1
local Director = Dora.Director -- 1
local print = _G.print -- 1
local View = Dora.View -- 1
local Vec2 = Dora.Vec2 -- 1
local Size = Dora.Size -- 1
local Sprite = Dora.Sprite -- 1
local DrawNode = Dora.DrawNode -- 1
local Color = Dora.Color -- 1
local math = _G.math -- 1
local Playable = Dora.Playable -- 1
local Label = Dora.Label -- 1
local tostring = _G.tostring -- 1
_ENV = Dora(Dora.ImGui) -- 2
_ENV = Dora(Dora.Command) -- 3
do -- 6
	local scriptPath = Path:getScriptPath(...) -- 6
	if scriptPath then -- 6
		local _list_0 = { -- 8
			scriptPath, -- 8
			Path(scriptPath, "Script"), -- 9
			Path(scriptPath, "Spine"), -- 10
			Path(scriptPath, "Image"), -- 11
			Path(scriptPath, "Font") -- 12
		} -- 7
		for _index_0 = 1, #_list_0 do -- 13
			local path = _list_0[_index_0] -- 7
			Content:insertSearchPath(1, path) -- 14
		end -- 14
	else -- 15
		return -- 15
	end -- 6
end -- 6
local Command = require("System.Command") -- 17
local Config = require("Data.Config") -- 18
local AlignNode = require("AlignNode") -- 19
local main = AudioBus() -- 20
Audio.globalVolume = Config.volumeValue / 100 -- 21
Audio:playStream("Sound/memo1.mp3", true, 0.5) -- 22
App.fullScreen = Config.fullscreen -- 23
local SceneManager -- 28
do -- 28
	local _class_0 -- 28
	local _base_0 = { -- 28
		interfaces = { }, -- 30
		current = nil, -- 31
		container = nil, -- 34
		init = function(self) -- 34
			self.interfaces = { } -- 35
			self.current = nil -- 36
			self.container = Node() -- 38
			self.container:addTo(Director.ui) -- 39
			self.container.renderOrder = 100 -- 40
			return print("SceneManager 容器已创建并添加到 Director.ui") -- 41
		end, -- 44
		register = function(self, name, createFunc) -- 44
			self.interfaces[name] = createFunc -- 45
		end, -- 48
		switchTo = function(self, name, ...) -- 48
			if self.current then -- 50
				if self.current.node then -- 51
					self.current.node:removeFromParent() -- 51
				end -- 51
				if self.current.onLeave then -- 52
					self.current:onLeave(...) -- 53
				end -- 52
			end -- 50
			if self.interfaces[name] then -- 56
				self.current = self.interfaces[name](...) -- 57
				if self.current and self.current.node then -- 58
					self.current.node:addTo(self.container) -- 59
				end -- 58
				if self.current and self.current.onEnter then -- 60
					return self.current:onEnter(...) -- 61
				end -- 60
			else -- 63
				return print("界面未注册: " .. name) -- 63
			end -- 56
		end, -- 66
		getCurrent = function(self) -- 66
			return self.current -- 67
		end, -- 70
		clear = function(self) -- 70
			if self.current and self.current.node then -- 71
				self.current.node:removeFromParent() -- 72
			end -- 71
			self.interfaces = { } -- 73
			self.current = nil -- 74
		end -- 28
	} -- 28
	if _base_0.__index == nil then -- 28
		_base_0.__index = _base_0 -- 28
	end -- 74
	_class_0 = setmetatable({ -- 28
		__init = function() end, -- 28
		__base = _base_0, -- 28
		__name = "SceneManager" -- 28
	}, { -- 28
		__index = _base_0, -- 28
		__call = function(cls, ...) -- 28
			local _self_0 = setmetatable({ }, _base_0) -- 28
			cls.__init(_self_0, ...) -- 28
			return _self_0 -- 28
		end -- 28
	}) -- 28
	_base_0.__class = _class_0 -- 28
	SceneManager = _class_0 -- 28
end -- 74
SceneManager = SceneManager() -- 77
SceneManager:init() -- 78
local DesignSceneHeight <const> = 2160 -- 81
local DesignSceneWidth <const> = 3840 -- 82
local updateViewSize -- 87
updateViewSize = function() -- 87
	Director.currentCamera.zoom = View.size.height / DesignSceneHeight -- 88
end -- 87
updateViewSize() -- 90
Director.entry:onAppChange(function(settingName) -- 92
	if settingName == "Size" then -- 93
		return updateViewSize() -- 94
	end -- 93
end) -- 92
local createLogoButton -- 97
createLogoButton = function(parent, logoPath, width, height, x, y, showDebug) -- 97
	local group = Node() -- 98
	group.position = Vec2(x or 0, y or 0) -- 99
	group:addTo(parent) -- 100
	print("按钮组节点已创建，位置: ", x, y) -- 101
	local touchNode = Node() -- 103
	touchNode.touchEnabled = true -- 104
	touchNode.size = Size(width, height) -- 105
	touchNode:addTo(group) -- 106
	local displayNode = Node() -- 108
	displayNode:addTo(group) -- 109
	local logo = Sprite(logoPath) -- 112
	if logo then -- 113
		logo.size = Size(width, height) -- 114
		logo:addTo(displayNode) -- 115
		logo.renderOrder = 1 -- 116
		print("Logo图片加载成功，尺寸: ", width, height) -- 117
	else -- 119
		print("图片加载失败: " .. logoPath) -- 119
		local placeholder = DrawNode() -- 121
		placeholder:drawPolygon({ -- 123
			Vec2(-width / 2, -height / 2), -- 123
			Vec2(width / 2, -height / 2), -- 124
			Vec2(width / 2, height / 2), -- 125
			Vec2(-width / 2, height / 2) -- 126
		}, Color(0, 255, 0, 255)) -- 122
		placeholder:addTo(displayNode) -- 128
		placeholder.renderOrder = 1 -- 129
	end -- 113
	touchNode:slot("TapBegan", function() -- 132
		print("TapBegan 信号触发") -- 133
		displayNode.opacity = 0.7 -- 134
	end) -- 132
	touchNode:slot("TapEnded", function() -- 136
		displayNode.opacity = 1.0 -- 137
		return print("按钮点击 TapEnded") -- 138
	end) -- 136
	touchNode:slot("TapMoved", function(touch) -- 140
		local localPos = touchNode:convertToNodeSpace(touch.location) -- 141
		if math.abs(localPos.x) > width / 2 or math.abs(localPos.y) > height / 2 then -- 142
			displayNode.opacity = 1.0 -- 143
		end -- 142
	end) -- 140
	return group, logo, touchNode -- 145
end -- 97
local createMainMenu -- 148
createMainMenu = function() -- 148
	local interface = { } -- 149
	interface.node = Node() -- 150
	local root = AlignNode(true) -- 153
	root:css("justify-content: center; align-items: center") -- 154
	root:addTo(interface.node) -- 155
	local centerNode = AlignNode() -- 158
	centerNode:css("width: 100%; height: 100%") -- 159
	centerNode:addTo(root) -- 160
	local bg = Sprite("asset/background1.jpg") -- 162
	bg:addTo(centerNode) -- 163
	bg.filter = "Point" -- 164
	local dragonback = Playable("bone:asset/NewProject/NewProject") -- 167
	if dragonback then -- 168
		dragonback:addTo(centerNode) -- 169
		dragonback:play("Sprite", true) -- 170
		dragonback.zOrder = -1 -- 171
		print("DragonBones 动画加载成功") -- 172
	else -- 174
		print("DragonBones 动画加载失败，使用静态背景") -- 174
	end -- 168
	local actualWidth, actualHeight -- 176
	centerNode:onAlignLayout(function(width, height) -- 177
		actualWidth = width -- 178
		actualHeight = height -- 179
		bg.position = Vec2(width / 2, height / 2) -- 182
		bg.size = Size(width, height) -- 183
		if dragonback then -- 186
			dragonback.position = Vec2(width / 2, height / 2) -- 187
			local scaleX = width / DesignSceneWidth / 1.5 -- 188
			local scaleY = height / DesignSceneHeight / 1.5 -- 189
			local scale = math.max(scaleX, scaleY) -- 190
			dragonback.scaleX = scale * 10 -- 191
			dragonback.scaleY = scale * 10 -- 192
			dragonback.zOrder = -1 -- 193
		end -- 186
	end) -- 177
	local gametitle = Sprite("asset/logo1.png") -- 196
	gametitle:addTo(centerNode) -- 197
	gametitle.size = Size(400, 400) -- 198
	gametitle.filter = "Point" -- 199
	gametitle.renderOrder = 1 -- 200
	local startButton, logostart, startTouchNode = createLogoButton(centerNode, "asset/start.png", 200, 200, 0, 0, true) -- 206
	startButton.renderOrder = 2 -- 207
	local settingsButton, logosettings, settingsTouchNode = createLogoButton(centerNode, "asset/settings.png", 200, 200, 0, 0, true) -- 210
	settingsButton.renderOrder = 2 -- 211
	local continueButton, logocontinue, continueTouchNode = createLogoButton(centerNode, "asset/ctn.png", 200, 200, 0, 0, true) -- 214
	continueButton.renderOrder = 2 -- 215
	startTouchNode:slot("TapEnded", function() -- 218
		print("新的点击事件：切换到游戏场景") -- 219
		return Command.chapter("dream1.yarn") -- 220
	end) -- 218
	settingsTouchNode:slot("TapEnded", function() -- 222
		return SceneManager:switchTo("GameScene") -- 223
	end) -- 222
	continueTouchNode:slot("TapEnded", function() -- 225
		print("新的点击事件：继续游戏") -- 226
		return Command.chapter(Config.chapterctn) -- 227
	end) -- 225
	centerNode:schedule(function() -- 230
		if actualWidth and actualHeight then -- 231
			gametitle.position = Vec2(actualWidth / 2, actualHeight * 0.85) -- 233
			local buttonStartY = actualHeight * 0.85 - 400 -- 236
			local buttonSpacing = 150 -- 237
			startButton.position = Vec2(actualWidth / 2, buttonStartY) -- 240
			continueButton.position = Vec2(actualWidth / 2, buttonStartY - buttonSpacing * 2) -- 243
			settingsButton.position = Vec2(actualWidth / 2, buttonStartY - buttonSpacing * 4) -- 246
		end -- 231
	end) -- 230
	interface.onEnter = function(self) -- 250
		print("进入主菜单") -- 251
		if dragonback and not dragonback.playing then -- 252
			return dragonback:play("Sprite", true) -- 253
		end -- 252
	end -- 250
	interface.onLeave = function(self) -- 255
		print("离开主菜单") -- 256
		if dragonback and dragonback.playing then -- 257
			return dragonback:stop() -- 258
		end -- 257
	end -- 255
	return interface -- 261
end -- 148
local createGameScene -- 265
createGameScene = function() -- 265
	local interface = { } -- 266
	interface.node = Node() -- 267
	local root = AlignNode(true) -- 270
	root:css("justify-content: center; align-items: center") -- 271
	root:addTo(interface.node) -- 272
	local centerNode = AlignNode() -- 275
	centerNode:css("width: 100%; height: 100%") -- 276
	centerNode:addTo(root) -- 277
	local gameBg = Sprite("asset/background1.jpg") -- 280
	gameBg:addTo(centerNode) -- 281
	local actualWidth, actualHeight -- 283
	centerNode:onAlignLayout(function(width, height) -- 284
		actualWidth = width -- 285
		actualHeight = height -- 286
		print("设置场景布局: ", width, height) -- 287
		gameBg.position = Vec2(width / 2, height / 2) -- 290
		gameBg.size = Size(width, height) -- 291
	end) -- 284
	local settingsContainer = Node() -- 294
	settingsContainer:addTo(centerNode) -- 295
	local settingsBg = Sprite("asset/blankbtn.png") -- 298
	settingsBg.size = Size(1000, 500) -- 299
	settingsBg.opacity = 0.7 -- 300
	settingsBg:addTo(settingsContainer) -- 301
	local fullscreenText = Label("SourceHanSansCN-Regular", 50) -- 304
	fullscreenText.text = "全屏模式:" -- 305
	fullscreenText.color = Color(0, 0, 0, 255) -- 306
	fullscreenText.position = Vec2(-250, 100) -- 307
	fullscreenText:addTo(settingsContainer) -- 308
	local fullscreenToggle, fullscreenToggleLogo, fullscreenToggleTouch = createLogoButton(settingsContainer, "asset/blankbtn.png", 60, 60, 0, 100, true) -- 311
	local toggleText = Label("SourceHanSansCN-Regular", 30) -- 314
	toggleText.text = Config.fullscreen and "开" or "关" -- 315
	toggleText.color = Color(0, 0, 0, 255) -- 316
	toggleText:addTo(fullscreenToggle) -- 317
	fullscreenToggleTouch:slot("TapEnded", function() -- 319
		Config.fullscreen = not Config.fullscreen -- 320
		toggleText.text = Config.fullscreen and "开" or "关" -- 321
		print("全屏模式: " .. tostring(Config.fullscreen)) -- 322
		App.fullScreen = Config.fullscreen -- 323
	end) -- 319
	local volumeText = Label("SourceHanSansCN-Regular", 50) -- 326
	volumeText.text = "背景音量:" -- 327
	volumeText.color = Color(0, 0, 0, 255) -- 328
	volumeText.position = Vec2(-250, 0) -- 329
	volumeText:addTo(settingsContainer) -- 330
	local volumeDisplay = Label("SourceHanSansCN-Regular", 50) -- 332
	volumeDisplay.text = tostring(Config.volumeValue) .. "%" -- 333
	volumeDisplay.color = Color(0, 0, 0, 255) -- 334
	volumeDisplay.position = Vec2(-50, 0) -- 335
	volumeDisplay:addTo(settingsContainer) -- 336
	Config.audioBus = main -- 338
	Config.audioBus.volume = Config.volumeValue / 100 -- 339
	local volumeUp, volumeUpLogo, volumeUpTouch = createLogoButton(settingsContainer, "asset/blankbtn.png", 60, 60, 50, 0, true) -- 342
	local upText = Label("SourceHanSansCN-Regular", 40) -- 344
	upText.text = "+" -- 345
	upText.color = Color(0, 0, 0, 255) -- 346
	upText:addTo(volumeUp) -- 347
	volumeUpTouch:slot("TapEnded", function() -- 349
		if Config.volumeValue < 100 then -- 350
			Config.volumeValue = Config.volumeValue + 10 -- 351
			volumeDisplay.text = tostring(Config.volumeValue) .. "%" -- 352
			Config.audioBus.volume = Config.volumeValue / 100 -- 353
			Audio.globalVolume = Config.volumeValue / 100 -- 354
		end -- 350
	end) -- 349
	local volumeDown, volumeDownLogo, volumeDownTouch = createLogoButton(settingsContainer, "asset/blankbtn.png", 60, 60, 120, 0, true) -- 357
	local downText = Label("SourceHanSansCN-Regular", 40) -- 359
	downText.text = "-" -- 360
	downText.color = Color(0, 0, 0, 255) -- 361
	downText:addTo(volumeDown) -- 362
	volumeDownTouch:slot("TapEnded", function() -- 364
		if Config.volumeValue > 0 then -- 365
			Config.volumeValue = Config.volumeValue - 10 -- 366
			volumeDisplay.text = tostring(Config.volumeValue) .. "%" -- 367
			Config.audioBus.volume = Config.volumeValue / 100 -- 368
			Audio.globalVolume = Config.volumeValue / 100 -- 369
		end -- 365
	end) -- 364
	local backButton, backLogo, backTouchNode = createLogoButton(centerNode, "asset/back.png", 200, 200, 0, 0, true) -- 372
	backButton.renderOrder = 2 -- 373
	backTouchNode:slot("TapEnded", function() -- 376
		print("返回按钮点击，切换回主菜单") -- 377
		return SceneManager:switchTo("MainMenu") -- 378
	end) -- 376
	local sceneText = Label("SourceHanSansCN-Regular", 80) -- 381
	sceneText.text = "游戏设置" -- 382
	sceneText:addTo(centerNode) -- 383
	centerNode:schedule(function() -- 386
		if actualWidth and actualHeight then -- 387
			print("=== 设置界面位置更新 ===") -- 388
			print("屏幕尺寸: " .. tostring(actualWidth) .. ", " .. tostring(actualHeight)) -- 389
			sceneText.position = Vec2(actualWidth / 2, actualHeight * 0.85) -- 392
			print("场景标题位置: " .. tostring(sceneText.position.x) .. ", " .. tostring(sceneText.position.y)) -- 393
			settingsContainer.position = Vec2(actualWidth / 2, actualHeight / 2) -- 396
			print("设置容器位置: " .. tostring(settingsContainer.position.x) .. ", " .. tostring(settingsContainer.position.y)) -- 397
			settingsBg.position = Vec2(0, 0) -- 400
			backButton.position = Vec2(120, 120) -- 403
			return print("返回按钮位置: " .. tostring(backButton.position.x) .. ", " .. tostring(backButton.position.y)) -- 404
		end -- 387
	end) -- 386
	interface.onEnter = function(self) -- 408
		print("进入设置场景") -- 409
		if actualWidth and actualHeight then -- 413
			sceneText.position = Vec2(actualWidth / 2, actualHeight * 0.85) -- 414
			settingsContainer.position = Vec2(actualWidth / 2, actualHeight / 2) -- 415
			backButton.position = Vec2(120, 120) -- 416
		end -- 413
	end -- 408
	interface.onLeave = function(self) -- 418
		return print("离开设置场景") -- 419
	end -- 418
	return interface -- 421
end -- 265
SceneManager:register("MainMenu", createMainMenu) -- 423
SceneManager:register("GameScene", createGameScene) -- 424
SceneManager:switchTo("MainMenu") -- 427
print("界面管理器初始化完成") -- 430
return print("屏幕尺寸:", View.size.width, View.size.height) -- 431
